#include <algorithm>
#include <iostream>

using namespace std;

int n, r;
int A[1100002], C[1100002];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> A[i];
  int i, j;
  for (i = n; i; i--) {
    int mayor = A[i];
    for (j = i + 1; j <= n && A[j] > A[i]; j++) {
      mayor = max(A[j], mayor);
      if (A[j] == A[i] + j - i && A[j] == mayor) {
        r++;
        C[i] = j;
        break;
      }
      if (C[j]) break;
    }
  }
  cout << r << "\n";
  for (i = 1; i <= n; i++)
    if (C[i]) cout << i << " " << C[i] << "\n";
  return 0;
}
